package com.blog.controller.user;

import com.blog.result.Result;
import com.blog.service.CategoryService;
import com.blog.vo.CategoryVO;
import com.blog.vo.userCategoryVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("userCategory")
@RequestMapping("/user/category")
@Slf4j
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/categoryList/{uid}")
    public Result<List<userCategoryVO>> ListCategory(@PathVariable("uid") Long uid){
        log.info("根据用户ID查询类别：{}",uid);
        List<userCategoryVO> list = categoryService.userCategoryList(uid);
        return Result.success(list);
    }
    @GetMapping("/getCategoryTotal/{uid}")
    public Result getCategoryTotal(@PathVariable("uid") Long uid){
        log.info("根据用户ID查询类别总数：{}",uid);
        Long total = categoryService.getCategoryTotal(uid);
        return Result.success(total);
    }

}
